package com.memo4android;

import com.memo4android.model.AppModel;
import com.memo4android.model.Dossier;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class NewNoteFolderActivity extends Activity implements OnClickListener {

		
		public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.frame_new_note_folder);
	        setTitle(this.getTitle() + " - New folder");
	        
	        ((Button)this.findViewById(R.id.buttonCancelNewNoteFolder)).setOnClickListener((android.view.View.OnClickListener) this);
	        ((Button)this.findViewById(R.id.buttonValidNewNoteFolder)).setOnClickListener((android.view.View.OnClickListener) this);
	        
		}
		
	    @Override
	    public void onBackPressed(){
			Intent intent_allnotes = new Intent(this ,MainView.class);
			intent_allnotes.putExtra("label", "all notes");
			this.startActivity(intent_allnotes);    	
	    }

		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch(v.getId()){
			
				case R.id.buttonValidNewNoteFolder:
					AppModel model = AppModel.getInstance(this);
					EditText editText= (EditText) findViewById(R.id.titleNewNoteFolder);
					Dossier dossier=new Dossier(editText.getText().toString());
					model.addDossier(dossier);
					Intent intentDossier = new Intent(this, InFolderActivity.class);
					intentDossier.putExtra("folderName", dossier.getTitre());
					this.startActivity(intentDossier);
					this.finish();
					break;
					
				case R.id.buttonCancelNewNoteFolder:
					this.finish();
					break;
			}
			
		}
		
			
}
